<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String basePath = request.getContextPath();
//String path = request.getContextPath();
//String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试页面</title>
<script type="text/javascript" src="res/js/jquery-1.11.2.js"></script>
</head>
<body>

${message}
这是首页${users}
<div>
<input type="button" id="btn_sendJson" value="提交用户信息" />
<input type="button" id="btn_getUser" value="获取用户列表" />
用户信息：
<div id="results">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$("#btn_sendJson").click(function(){
		$.ajax({
			type:"POST",
			dataType:"json",
			url:"testRequest",
			data:{"userName":"测试用户名","user.userAddress":"测试地址"},
			success:function(data){
				console.info((data))

			},
			error:function(e){
				console.info("出错了：");
				console.info(e);
			}
		});
	});
	
	$("#btn_getUser").click(function(){
		$.ajax({
			type:"POST",
			dataType:"json",
			url:"getJson",
			success:function(data){
				console.info((data))

				$.each((data),function(i,user){
					$("#results").append(user.userName+"----"+user.password+"<br />");
				});
			},
			error:function(e){
				console.info("出错了：");
				console.info(e);
			}
		});
	});
});
</script>
</body>
</html>